#!/usr/bin/python
# -*- coding: UTF-8 -*-
from git import Git
import os

if __name__ == '__main__':
    parentPath = os.getcwd()
    print("当前工作目录："+parentPath)
    for pathStr in os.listdir(parentPath):
        if(pathStr.find('ccb')!=-1):
            print("进入目录："+pathStr)
            os.chdir(parentPath+'/'+pathStr)
            path = os.getcwd()
            print('已经进入目录：'+os.getcwd())
            current_repo = Git(path)
            branch = current_repo.execute('git symbolic-ref --short -q HEAD')
            print ('当前分支：'+branch)
            # print("更新代码 ：\n"+current_repo.execute('git pull upstream '+ branch))
            # print('推送代码：\n'+current_repo.execute('git fetch --all'))
            print('推送代码：\n'+current_repo.execute('git push origin '+ branch))
